import url from "@/request/requestUrl.js"
const request = (config) => {
    config.url = url.requestUrl + config.url;
    if (!config.data) config.data = {};
    config.timeout = 300000;

    return new Promise((resolve, reject) => {
        uni.request({
            ...config,
            success: (res) => {
                if (res.statusCode !== 200) {
                    reject({ message: `请求失败，状态码：${res.statusCode}` });
                    return;
                }
                resolve(res.data);
            },
            fail: (err) => {
                reject({ message: "网络错误，请稍后重试", ...err });
            }
        });
    });
};

export default request;